<template>
  <el-card shadow="never">
    <div slot="header">
      <el-button @click="handleBack">返回</el-button>
    </div>
    <el-tabs v-model="name">
      <el-tab-pane label="基础信息" name="1">
        <basic-index ref="basicIndex" />
      </el-tab-pane>
      <el-tab-pane label="资质信息" name="2">
        <file ref="file" />
      </el-tab-pane>
      <el-tab-pane label="业务员信息" name="6">
        <business ref="business" />
      </el-tab-pane>
      <el-tab-pane label="产品信息" name="5">
        <product-table ref="productTable" />
      </el-tab-pane>
      <el-tab-pane label="合同管理" name="3">
        <contract ref="contract" />
      </el-tab-pane>
      <el-tab-pane label="业务信息" name="4">
        <buy ref="buy" />
      </el-tab-pane>
      <el-tab-pane label="不良记录" name="7">
        <record ref="record" />
      </el-tab-pane>
    </el-tabs>
  </el-card>
</template>

<script>
import BasicIndex from './basic'
import Business from './business'
import File from './file'
import Contract from './contract'
import ProductTable from './product'
import Buy from './buy'
import Record from './record'
import { getSession, setSession, removeSession } from '@/utils/util'

export default {
  data() {
    return {
      name: '1',
      from: this.$route.params.from || getSession('supplierFrom')
    }
  },
  components: {
    BasicIndex,
    Business,
    File,
    Contract,
    ProductTable,
    Buy,
    Record
  },
  created() {
    console.log('from', this.$route.params, this.from)

    if (this.from) {
      setSession('supplierFrom', this.from)
    }
  },
  methods: {
    handleBack() {
      this.$router.go(-1)
      // if (this.from === 'supplier') {
      //   this.$router.push({ name: 'supplierInfo' })
      // } else {
      //   this.$router.push({ name: 'monitorIndex' })
      // }
    }
  },
  destroyed() {
    removeSession('supplierFrom')
  }
}
</script>

<style lang="less" scoped>
.link-wrapper {
  height: 43px;
  a {
    padding: 12px 16px;
    border: 1px solid #dcdcdc;
    border-right: none;
    color: #333333;
    &:last-child {
      border-right: 1px solid #dcdcdc;
    }
    &.router-link-exact-active {
      color: #1890ff;
      text-decoration: none;
    }
  }
}
</style>
